package fib

import (
	"fmt"
	"bufio"
	"io"
	"strings"
)

func Fibonacci() intGet {
	a,b := 0,1
	return func() int {
		a,b = b,a+b;
		return a
	}
}

type intGet func() int

func (g intGet) Read(p []byte) (n int, err error) {
	next := g();
	if next > 10000{
		return 0,io.EOF
	}
	s := fmt.Sprintf("%d\n",next)

	return strings.NewReader(s).Read(p)
}


func printFileContents(read io.Reader)  {
	scanner := bufio.NewScanner(read)
	for scanner.Scan()  {
		fmt.Println(scanner.Text())
	}

}

